package com.dys.test15;

/**
 * @className: com.dys.test15.CustomerThread
 * @description: 消费者线程
 * @author: pine cone
 * @version: v1.0.0
 * @createTime: 2024/08/20 下午8:32
 */
public class CustomerThread extends Thread {

    private final Product p;

    public CustomerThread(Product p) {
        this.p = p;
    }

    // 消费者消费10个商品
    @Override
    public void run() {
        for (int i = 1; i <= 10; i++) {// i:消费次数
            synchronized (p) {
                System.out.println("消费者" + i + "消费了：【" + p.getBrand() + "】====>" + p.getName());
            }
        }
    }
}
